package com.yue.rabbitmq.service.impl;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class RabbitMQProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendMsg(String exchange,String routeKey,String message) {
        String uuid = UUID.randomUUID().toString();
        System.out.println("uuid:"+uuid);
        CorrelationData d = new CorrelationData(uuid);
        rabbitTemplate.convertAndSend(exchange, routeKey, message,d);
    }
}
